$(function () {
    var contextPath;
    $(document).ready(function () {
        contextPath = $('#contextPath').val();
    });

    $('#login').click(function () {

        var loginName =$('#loginName').val();
        var passWord =$('#passWord').val();
        if(loginName == null || loginName=="" || loginName=="请输入用户名")
        {
            alert("用户名为空！");
            return ;
        }
        if(passWord == null| passWord=="" || passWord=="请输入密码")
        {
            alert("密码为空！");
            return ;
        }

        var data={loginName:loginName,passWord:passWord};
        $.ajax({
            type:'post',
            url:contextPath+'/login/login',
            data:data,
            success:function (data) {
                if(data.success == true)
                {
                    window.location.href=contextPath + '/login/main';
                }
                else
                {
                    alert(data.info);
                    return;
                }

            },
            error:function () {

            }
        });
    });

    $('#register').click(function () {
        window.location.href=contextPath + '/demo/page/demo/register';
    });
});